<?php

use Laravel\Lumen\Routing\Router;


/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$api = app('Dingo\Api\Routing\Router');

/** @var Router $router */

$router->get('/', function () use ($router) {
    return 'welcome blog api ~';
});


/**
 * @var Dingo\Api\Routing\Router $api
 * v1.0.0版本路由
 */
$api->version('v1.0.0', [
    'namespace' => 'App\Http\Controllers',
], function ($api) {
    /** @var \Dingo\Api\Routing\Router $api */
    $api->group([
        'middleware' => [
//            'throttle:9,0.05',
//            'laravel-cross',
//            'cross',
        ],
    ], function () use ($api) {
        $api->get('test','TestController@test');
        $api->get('algorithm', 'AlgorithmController@algorithm');//算法
        $api->post('timer','TestController@timer');
    });

    $api->group([],function () use ($api) {
        $api->post('login', 'AuthController@login');//登陆
        $api->post('register', 'AuthController@register');//注册
        $api->post('logout', 'AuthController@logout');//退出登陆
        $api->post('refresh', 'AuthController@refresh');//刷新token
    });

    $api->group([
        'namespace' => '\v1',
        'middleware' => [
//            'auth:api',
        ],
    ], function () use ($api) {
        $api->options('/{path:.*}',function ($path){});
        // gc-rds-ha
        $api->get('clusters-info', 'GcRdsHaController@test');
        $api->get('cluster/alias/{a}', 'GcRdsHaController@test1');
        $api->get('graceful-master-takeover-auto/{masterHost}/{masterPort}/{slaveHost}/{slavePort}', 'GcRdsHaController@test2');
        $api->get('graceful-master-takeover/{masterHost}/{masterPort}/{slaveHost}/{slavePort}', 'GcRdsHaController@test2');
        $api->get('raft-status', 'GcRdsHaController@test3');
        $api->get('topology/{host}/{port}', 'GcRdsHaController@topology');
        $api->get('discover/{host}/{port}', 'GcRdsHaController@discover');



        //gc-rds-ha vip
        $api->post('portal/vpc-service/web/v1/vip', 'GcRdsHaController@vip');
        $api->get('portal/vpc-service/web/v1/vips', 'GcRdsHaController@vips');
        $api->delete('portal/vpc-service/web/v1/vip/{id}', 'GcRdsHaController@vipDelete');
        $api->post('/portal/vpc-service/web/v1/vip/ecs/bind', 'GcRdsHaController@vipBind');




        //和agent服务端对接
        $api->get('createHa', 'GcRdsHaController@createHa');


        $api->get('aaaa', 'algorithmAndDataStruct\AlgorithmController@test');

        //用户信息
        $api->post('getUserInfo','users\UserController@UserInfo');
        //更新个人信息
        $api->post('upUserInfo','users\UserController@upUserInfo');
        //签到
        $api->post('setSign','users\SignRecordController@getSign');
        //签到记录
        $api->post('signRecord','users\SignRecordController@signRecord');
        //补签到
        $api->post('counterSign','users\SignRecordController@counterSign');

        //活动
        //新年活动大转盘抽奖
        $api->post('luckLoop','activity\LuckController@luckLoop');
        //抽检记录
        $api->get('luckLog','activity\LuckController@luckLog');
        $api->post('addDraw','activity\DrawController@addDraw');
        $api->get('drawList','activity\DrawController@drawList');
        //资源路由
        $api->resource('users','ExampleController',['only'=>['index','store','show','update']]);
    });
});
